<%@page import="com.crm.entity.Parts,com.crm.entity.Sources,com.crm.entity.Clientdet,java.util.*" %>
<%List<Parts> partslist =(List<Parts>)request.getAttribute("partslist");%>
<%List<Sources> sourcelist =(List<Sources>)request.getAttribute("slist");
Clientdet clientdet =(Clientdet)request.getAttribute("client");
System.out.println("Parts List Is:"+partslist);
System.out.println("Sources X000 List Is:"+sourcelist);
%>
<table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#C5E4EB">
<% %>
          <tr>
            <td width="27" height="30" align="left" valign="middle" background="<%=application.getContextPath()%>/images/table-box.jpg"  style="background-repeat:repeat-x">S.No</td>
            <td width="242" align="left" valign="middle" background="<%=application.getContextPath()%>/images/table-box.jpg"   style="background-repeat:repeat-x" bgcolor="#FFFFFF"> Part Number </td>
            <td width="242" align="left" valign="middle" background="<%=application.getContextPath()%>/images/table-box.jpg"   style="background-repeat:repeat-x" bgcolor="#FFFFFF"> Description </td>
              <%for(int j=0;j<sourcelist.size();j++){%>
              <td width="216" align="left" valign="middle" background="<%=application.getContextPath()%>/images/table-box.jpg"   style="background-repeat:repeat-x" bgcolor="#FFFFFF">
              <input class="col<%=j%> case" onclick='checkSources(this,"col<%=j%>")' type="checkbox" value="<%=sourcelist.get(j).getSourceName() %>" id="<%=sourcelist.get(j).getSourceName() %>" checked="checked"/><%=sourcelist.get(j).getSourceName() %></td>
              <%} %>
          </tr>
           <%  if(partslist!=null){
        	   for(int i=0;i<partslist.size();i++){  %>
          <tr>
            <td bgcolor="#FFFFFF">
            <input name="sno" type="text" value="<%=i+1 %>" size="5" />
            </td>
            <td align="left" valign="top" bgcolor="#FFFFFF">
            <input name="part<%=i+1%>" type="text" value="<%=partslist.get(i).getPrtnum() %>"  size="5"/><input name="partid<%=i+1%>" type="hidden" value="<%=partslist.get(i).getPartid() %>"  size="5"/></td>
            <td align="left" valign="top" bgcolor="#FFFFFF">
            <input name="desc<%=i+1%>" type="text" value="<%=partslist.get(i).getDescription()%>"  size="5"/></td>
             <%for(int j=0;j<sourcelist.size();j++){%>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input class="col<%=j%> case" type="checkbox" value="<%=sourcelist.get(j).getSourceName()%><%=i+1%>" id="<%=sourcelist.get(j).getSourceName()%><%=i+1%>" name="<%=sourcelist.get(j).getSourceName()%><%=i+1%>" checked="checked"/>
            <%}%>
          </tr>
          <%} }%>
          <tr><input type="hidden" name="rowCount" value="<%=partslist.size()%>" id="rowCount"/>
     		<input type="hidden" name="columnCount" value="<%=sourcelist.size()%>" id="columnCount"/>    
         </tr>
            
        </table>
        <table>
        <tr><td><input type="checkbox" value="selectAll" name="selectAll" id="selectAll" checked="checked"/>Select All Sources</td></tr>
        </table>
   
	    <div class="buttton-main">
	    <input class="button" type="submit" value="Export" id="submit"/>
	    <div  class="button"><a href="<%=application.getContextPath()%>/source/open.do">Add Source</a></div>
	  </div>
   <script type="text/javascript"><!--
   function checkSources(obj,cls){
	   $('.'+cls).attr('checked', obj.checked);
   }
   $("#exform").submit(function(){
	   var rowCount=$("#rowCount").val();
	   if(rowCount==null || rowCount==0){
		   alert("There Is No Rows To Export");
		   return false;
	   }
		 var refid=$("#reflistid").val();
		 if(refid==null || refid==""){
			 jAlert("Please Select Reference Number");
			 return false;
		 }
		 else{
			 window.open('<%=application.getContextPath()%>/jsp/sendMailPopUp.jsp?reflist='+refid,"SendMail PopUp","scrollbars=1,menubar=1,resizable=0,width=950,height=400"); 
		 }
		
   });
   $("#selectAll").change(function(){
	          $('.case').attr('checked', this.checked);
   });
	 $(function(){
		 var client="<%=clientdet.getOrganisation()%>";
		 var cldiv="<%=clientdet.getDivision()%>";
		 var cluser="<%=request.getAttribute("user")%>";
		 $("#enqclient").html("Client Name Is:<span class='cliendet'>"+client +
		"</span>   &nbsp;&nbsp;&nbsp;&nbsp;  Client Division Is:<span class='cliendet'>"+cldiv+
		 "</span>    &nbsp;&nbsp;&nbsp;&nbsp;    Client User Is:<span class='cliendet'>"+cluser+"</span>");
		 $("#enqclient").show();
	 });
	    
   </script>    